package com.inspur.edp.common.expr.expresses.field;


import com.inspur.edp.common.expr.Express;
import com.inspur.edp.common.expr.ExpressDSLGenerator;
import com.inspur.edp.common.expr.ExpressDSLGeneratorMgr;
import com.inspur.edp.common.expr.ast.ASTContext;

/**
 * @author lizhaorui
 * @description TODO
 * @date 2024/12/17 10:37
 */
public class FieldAccessDSL implements ExpressDSLGenerator {

    @Override
    public String getKind() {
        return FieldAccessExpr.KIND;
    }

    @Override
    public String generate(ASTContext context, Express express) {
        FieldAccessExpr fieldAccessExpr = (FieldAccessExpr) express;
        String objectDsl = ExpressDSLGeneratorMgr.generateDsl(context, fieldAccessExpr.getObjectExpr());
        return String.format("%s.%s", objectDsl, fieldAccessExpr.getFieldCode());
    }
}
